package com.ugtss.busniess.controller;

import com.ugtss.busniess.domain.Student;
import com.ugtss.busniess.utils.DatabaseExportUtil;
import com.ugtss.common.annotation.Anonymous;
import com.ugtss.common.core.domain.AjaxResult;
import com.ugtss.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@RestController
@RequestMapping("/api/database")
public class DatabaseController {

    @Autowired
    private DatabaseExportUtil exportUtil;


    @GetMapping("getList")
    public AjaxResult list()
    {
        List<String> list = exportUtil.getSqlList();
        return AjaxResult.success(list);
    }


    @GetMapping("copy")
    public AjaxResult copy() throws IOException {
        exportUtil.getTableCreate();
        return AjaxResult.success();
    }

    @GetMapping("use/{fileName}")
    public AjaxResult use(@PathVariable String fileName) {
        return AjaxResult.success(exportUtil.use(fileName));
    }

    @DeleteMapping("/{fileName}")
    public AjaxResult delete(@PathVariable String fileName) {
        return AjaxResult.success(exportUtil.delete(fileName));
    }
}
